package com.android.Translator.Presenter;

import java.util.ArrayList;

import android.app.Activity;

import com.android.Translator.Model.TranslatorModel;
import com.android.Translator.View.AddWordToLearn;
import com.android.Translator.View.TranslatorActivity;
import com.example.entity.DataSearch;

public class TranslatorPresenter {

	private static Activity m_View;
	private static TranslatorModel	  m_Model;
	
	//[Quan] - constructor cua TranslatorPresenter
	public TranslatorPresenter(Activity m_View) {
		super();
		TranslatorPresenter.m_View = m_View;
		TranslatorPresenter.m_Model = new TranslatorModel(m_View);
	}
	//end
	
	//nhanvt add start
	public static void setResultToListLocalView(DataSearch Result)
	{
		((TranslatorActivity) m_View).setAdapterForListLocalView(Result);
	}
	//nhanvt add end
	
	//[Quan] -- Ham nay duoc goi tu lop View sau su kien click button
	//no goi ham translate ben lop Model
	public static void Translate(Activity activity, String inputText)
	{
		if (m_Model == null)
			m_Model = new TranslatorModel(activity);
		m_Model.Translate(activity, inputText, false,null);	
	}
	
	public static void TranslateWordAdd(Activity activity, String inputText, String editGroup)
	{
		if (m_Model == null)
			m_Model = new TranslatorModel(activity);
		m_Model.Translate(activity, inputText, true, editGroup);	
	}
	//end

	public static ArrayList<String> getMyWords(Activity activity, String GroupName) {
		// TODO Auto-generated method stub
		if (m_Model == null)
			m_Model = new TranslatorModel(activity);
		return m_Model.getMyWords(GroupName);
	}

	public static ArrayList<String> getGroupList(Activity activity) {
		// TODO Auto-generated method stub
		if (m_Model == null)
			m_Model = new TranslatorModel(activity);
		return m_Model.getGroupList();
	}

	public static void AddGroup(Activity activity, String string) {
		// TODO Auto-generated method stub
		if (m_Model == null)
			m_Model = new TranslatorModel(activity);
		m_Model.addGroup(string);
	}

	public static void showFinishDialog() {
		// TODO Auto-generated method stub
		AddWordToLearn.showFinishDialog();
	}

	public static void showProcessCircle() {
		// TODO Auto-generated method stub
		AddWordToLearn.showProcessCircle();
	}

	public static void dismissProcessCircle() {
		// TODO Auto-generated method stub
		AddWordToLearn.dismissProcessCircle();
	}
}
